lteiot23 2.2.0
Loading...
Searching...
No Matches
main.c File Reference

LTE IoT 23 Click Example. More...

#include "board.h"
#include "log.h"
#include "lteiot23.h"
#include "conversions.h"

Macros

#define EXAMPLE_TCP_UDP   0
#define EXAMPLE_SMS   1
#define DEMO_EXAMPLE   EXAMPLE_TCP_UDP
#define SIM_APN   ""
#define SIM_SMSC   ""
#define PHONE_NUMBER   ""
#define SMS_MODE   "1"
#define REMOTE_IP   "54.187.244.144"
#define REMOTE_PORT   "51111"
#define MESSAGE_CONTENT   "LTE IoT 23 Click board - demo example."
#define APP_BUFFER_SIZE   256
#define PROCESS_BUFFER_SIZE   256
#define MIN_FUNCTIONALITY   "0"
#define FULL_FUNCTIONALITY   "1"
#define ENABLE_REG   "2"
#define PDP_CID   "1"
#define ENABLE_SOCKET_EVENTS   "0,1"
#define SOCKET_CMD_ALLOCATE   "ALLOCATE"
#define SOCKET_CMD_ACTIVATE   "ACTIVATE"
#define SOCKET_CMD_SEND   "SEND"
#define SOCKET_CMD_RECEIVE   "RECEIVE"
#define SOCKET_CMD_DELETE   "DELETE"
#define TCP_SOCKET_NUM   "1"
#define TCP_CONN_TYPE   "TCP"
#define CONN_MODE   "OPEN"
#define UDP_SOCKET_NUM   "1"
#define UDP_CONN_TYPE   "UDP"

Enumerations

enum  lteiot23_app_state_t {
  LTEIOT23_POWER_UP = 1 , LTEIOT23_CONFIG_CONNECTION , LTEIOT23_CHECK_CONNECTION , LTEIOT23_CONFIG_EXAMPLE ,
  LTEIOT23_EXAMPLE
}
 Example states. More...

Functions

void application_init (void)
void application_task (void)
int main (void)

Detailed Description

LTE IoT 23 Click Example.

Description

Application example shows device capability of connecting to the network and sending SMS or TCP/UDP messages using standard "AT" commands.

The demo application is composed of two sections :

Application Init

Initializes the driver and logger.

Application Task

Application task is split in few stages:

  • LTEIOT23_POWER_UP: Powers up the device, performs a factory reset and reads system information.
  • LTEIOT23_CONFIG_CONNECTION: Sets configuration to device to be able to connect to the network.
  • LTEIOT23_CHECK_CONNECTION: Waits for the network registration indicated via CEREG command and then checks the signal quality report.
  • LTEIOT23_CONFIG_EXAMPLE: Configures device for the selected example.
  • LTEIOT23_EXAMPLE: Depending on the selected demo example, it sends an SMS message (in PDU or TXT mode) or TCP/UDP message.

By default, the TCP/UDP example is selected.

Additional Function

  • static void lteiot23_clear_app_buf ( void )
  • static void lteiot23_log_app_buf ( void )
  • static err_t lteiot23_process ( lteiot23_t *ctx )
  • static err_t lteiot23_read_response ( lteiot23_t *ctx, uint8_t *rsp, uint32_t max_rsp_time )
  • static err_t lteiot23_power_up ( lteiot23_t *ctx )
  • static err_t lteiot23_config_connection ( lteiot23_t *ctx )
  • static err_t lteiot23_check_connection ( lteiot23_t *ctx )
  • static err_t lteiot23_config_example ( lteiot23_t *ctx )
  • static err_t lteiot23_example ( lteiot23_t *ctx )
Note
In order for the examples to work, user needs to set the APN and SMSC (SMS PDU mode only) of entered SIM card as well as the phone number (SMS mode only) to which he wants to send an SMS. Enter valid values for the following macros: SIM_APN, SIM_SMSC and PHONE_NUMBER. Example: SIM_APN "internet" SIM_SMSC "+381610401" PHONE_NUMBER "+381659999999"
Author
Stefan Filipovic

Macro Definition Documentation

◆ APP_BUFFER_SIZE

#define APP_BUFFER_SIZE   256

◆ CONN_MODE

#define CONN_MODE   "OPEN"

◆ DEMO_EXAMPLE

#define DEMO_EXAMPLE   EXAMPLE_TCP_UDP

◆ ENABLE_REG

#define ENABLE_REG   "2"

◆ ENABLE_SOCKET_EVENTS

#define ENABLE_SOCKET_EVENTS   "0,1"

◆ EXAMPLE_SMS

#define EXAMPLE_SMS   1

◆ EXAMPLE_TCP_UDP

#define EXAMPLE_TCP_UDP   0

◆ FULL_FUNCTIONALITY

#define FULL_FUNCTIONALITY   "1"

◆ MESSAGE_CONTENT

#define MESSAGE_CONTENT   "LTE IoT 23 Click board - demo example."

◆ MIN_FUNCTIONALITY

#define MIN_FUNCTIONALITY   "0"

◆ PDP_CID

#define PDP_CID   "1"

◆ PHONE_NUMBER

#define PHONE_NUMBER   ""

◆ PROCESS_BUFFER_SIZE

#define PROCESS_BUFFER_SIZE   256

◆ REMOTE_IP

#define REMOTE_IP   "54.187.244.144"

◆ REMOTE_PORT

#define REMOTE_PORT   "51111"

◆ SIM_APN

#define SIM_APN   ""

◆ SIM_SMSC

#define SIM_SMSC   ""

◆ SMS_MODE

#define SMS_MODE   "1"

◆ SOCKET_CMD_ACTIVATE

#define SOCKET_CMD_ACTIVATE   "ACTIVATE"

◆ SOCKET_CMD_ALLOCATE

#define SOCKET_CMD_ALLOCATE   "ALLOCATE"

◆ SOCKET_CMD_DELETE

#define SOCKET_CMD_DELETE   "DELETE"

◆ SOCKET_CMD_RECEIVE

#define SOCKET_CMD_RECEIVE   "RECEIVE"

◆ SOCKET_CMD_SEND

#define SOCKET_CMD_SEND   "SEND"

◆ TCP_CONN_TYPE

#define TCP_CONN_TYPE   "TCP"

◆ TCP_SOCKET_NUM

#define TCP_SOCKET_NUM   "1"

◆ UDP_CONN_TYPE

#define UDP_CONN_TYPE   "UDP"

◆ UDP_SOCKET_NUM

#define UDP_SOCKET_NUM   "1"

Enumeration Type Documentation

◆ lteiot23_app_state_t

Example states.

Predefined enum values for application example state.

Enumerator
LTEIOT23_POWER_UP 
LTEIOT23_CONFIG_CONNECTION 
LTEIOT23_CHECK_CONNECTION 
LTEIOT23_CONFIG_EXAMPLE 
LTEIOT23_EXAMPLE 

Function Documentation

◆ application_init()

void application_init ( void )

< Logger config object.

< Click config object.

Logger initialization. Default baud rate: 115200 Default log level: LOG_LEVEL_DEBUG

Note
If USB_UART_RX and USB_UART_TX are defined as HAL_PIN_NC, you will need to define them manually for log to work. See LOG_MAP_USB_UART macro definition for detailed explanation.

◆ application_task()

void application_task ( void )

◆ main()

int main ( void )